package com.liuche.pictureserver.config;

import com.liuche.pictureserver.process.picture.PictureCheckProcess;
import com.liuche.pictureserver.process.picture.PictureInfoFillProcess;
import com.liuche.pictureserver.process.picture.PictureUploadProcess;
import com.liuche.pictureserver.process.picture.PictureUploadProcessTemplate;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 责任链相关Bean
 *
 * @author liuche
 */
@Configuration
public class ProcessConfig {
    @Resource
    private PictureCheckProcess pictureCheckProcess;
    @Resource
    private PictureInfoFillProcess pictureInfoFillProcess;
    @Resource
    private PictureUploadProcess pictureUploadProcess;

    /**
     * 创建图片上传责任链
     * @return 图片上传责任链
     */
    @Bean("pictureUploadProcessTemplate")
    public PictureUploadProcessTemplate processTemplate() {
        PictureUploadProcessTemplate pictureUploadProcessTemplate = new PictureUploadProcessTemplate();
        pictureUploadProcessTemplate.addHandler(pictureCheckProcess);
        pictureUploadProcessTemplate.addHandler(pictureInfoFillProcess);
        pictureUploadProcessTemplate.addHandler(pictureUploadProcess);
        return pictureUploadProcessTemplate;
    }
}
